﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Windows.Forms;
using BusinessLayer;
using System.Data;

namespace Design
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                        
        }

        protected void btnCart_Click(object sender, EventArgs e)
        {
            
        }

        protected void DataList1_ItemCommand(object source, System.Web.UI.WebControls.CommandEventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect("/Login.aspx");
            }
            else
            {
                MembershipUser user = Membership.GetUser();
                ShoppingCart objcart = new ShoppingCart();

                System.Web.UI.WebControls.Label lblequip = (System.Web.UI.WebControls.Label)DataList1.Items[0].FindControl("EquipIDLabel");
                System.Web.UI.WebControls.Label lblequipnm = (System.Web.UI.WebControls.Label)DataList1.Items[0].FindControl("NameLabel");
                System.Web.UI.WebControls.Label lblprice = (System.Web.UI.WebControls.Label)DataList1.Items[0].FindControl("PriceLabel");
                System.Web.UI.WebControls.Image imgImage = (System.Web.UI.WebControls.Image)DataList1.Items[0].FindControl("Image2");

                objcart.userid = user.ProviderUserKey.ToString();
                //objcart.equip_id = lblequip.Text;
                objcart.equip_name = lblequipnm.Text;
                objcart.price = Convert.ToDecimal(lblprice.Text);
                objcart.image = imgImage.ImageUrl;

                //objcart.add_to_cart();
            }
        }
    }
}